#include #include using namespace std; void main() { //char s1[1000]; //char s2[1000]; //cin.getline(s1,1000); //cin.getline(s2,1000); //// <0 , >0, == 0 ////<0 when s1 is less than s2 ////>0 when s1 is greater than s2 ////lexographical comparison //if(strcmp(s1,s2) == 0) //{ // cout << "Same" << endl; //} //else //{ // cout << "Different" << endl; // cout << strcmp(s1,s2) << endl; //} //if(stricmp(s1,s2) == 0) //{ // cout << "Same (case insensitive)" << endl; //} //else //{ // cout << "Different (case insensitive)" << endl; //} ////only compares the first n chars //if(strncmp(s1,s2,4) == 0) //{ // cout << "Same (first four chars)" << endl; //} //else //{ // cout << "Different (first four chars)" << endl; //} ////only compares the first n chars //if(strnicmp(s1,s2,4) == 0) //{ // cout << "Same (first four chars, case insensitive)" << endl; //} //else //{ // cout << "Different (first four chars, case insensitive)" << endl; //} ////not for c-style strings ////if(s1 == s2) ////{ ////} char s3[1000]; cin.getline(s3,1000); //cout << s3 + 7 << endl; char lastPart[123]; //strcpy(lastPart, s3+2); //cout << lastPart << endl; if(strchr(s3,'z') != NULL) { cout << "Found a z" << endl; cout << strchr(s3,'z') << endl; } else { cout << "Did not find a z" << endl; } if(strstr(s3,"Waldo") != NULL) { cout << "Found Waldo" << endl; cout << strstr(s3,"Waldo") << endl; } else { cout << "Did not find Waldo" << endl; } int count = 0; char* p = strchr(s3, 'a'); while(p != NULL) { count++; p = strchr(p + 1, 'a'); } cout << "There are " << count << " a's in " << s3 << endl; }